home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / allfiles / Itch / itch_Browser.dcr / Internal_55_urlParent.ls < prev    next >
Encoding:
Text File  |  1999-03-08  |  3.2 KB  |  165 lines

  1. property saveList, saveUrllist, urlList, memberName
  2. global world, vitualObj, CD
  3.  
  4. on new me, aList
  5.   me.memberName = "urlParent"
  6.   put EMPTY into field "urlList"
  7.   saveList = [#urlList]
  8.   saveUrllist = [#urlList]
  9.   urlList = []
  10.   if listp(aList) then
  11.     tempL = getaProp(aList, #urlList)
  12.     repeat with x = 1 to count(tempL)
  13.       aList = getAt(tempL, x)
  14.       aName = getaProp(aList, #name)
  15.       add(urlList, new(script(aName), aList, 0))
  16.     end repeat
  17.   else
  18.   end if
  19.   loadLocal(me)
  20.   return me
  21. end
  22.  
  23. on loadLocal me
  24.   if CD = 1 then
  25.     tell the stage
  26.       readText("itchLink")
  27.     end tell
  28.     itchLink = value(the result)
  29.   else
  30.     if voidp(getPref("itchLink")) then
  31.       SetPref("itchLink", string([:]))
  32.     end if
  33.     itchLink = value(getPref("itchLink"))
  34.   end if
  35.   repeat with x = 1 to count(itchLink)
  36.     p = getPropAt(itchLink, x)
  37.     obj = getObjfromUID(me, p)
  38.     if objectp(obj) then
  39.       aList = getAt(itchLink, x)
  40.       if listp(aList) then
  41.         put getaProp(aList, #version) && obj.version
  42.         if voidp(getaProp(aList, #played)) then
  43.           next repeat
  44.         end if
  45.         if getaProp(aList, #version) = obj.version then
  46.           obj.played = getaProp(aList, #played)
  47.         end if
  48.       end if
  49.     end if
  50.   end repeat
  51. end
  52.  
  53. on saveLocal me
  54.   temp = [:]
  55.   repeat with x in urlList
  56.     if x.played then
  57.       addProp(temp, x.uniqueID, [#played: x.played, #version: x.version])
  58.     end if
  59.   end repeat
  60.   if CD = 1 then
  61.     tell the stage
  62.       saveText("itchLink", string(temp))
  63.     end tell
  64.   else
  65.     SetPref("itchLink", string(temp))
  66.   end if
  67. end
  68.  
  69. on getIDfromLine me, num
  70.   if count(urlList) < num then
  71.     return 0
  72.   end if
  73.   temp = getAt(urlList, num)
  74.   if not objectp(temp) then
  75.     return 0
  76.   end if
  77.   return temp.uniqueID
  78. end
  79.  
  80. on getNameFromUID me, link
  81.   obj = getObjfromUID(me, link)
  82.   if obj = 0 then
  83.     return 0
  84.   end if
  85.   temp = obj.fileNam
  86.   if temp = 0 then
  87.     return 0
  88.   end if
  89.   return temp
  90. end
  91.  
  92. on deteteUrl me, path
  93.   temp = getObjFromPath(me, path)
  94.   if temp = 0 then
  95.     return 0
  96.   end if
  97.   deleteURL(world, temp.uniqueID)
  98.   deleteOne(urlList, temp)
  99.   return 1
  100. end
  101.  
  102. on getObjFromPath me, path
  103.   repeat with x in urlList
  104.     if x.originalpath = path then
  105.       return x
  106.     end if
  107.   end repeat
  108.   return 0
  109. end
  110.  
  111. on getObjfromUID me, link
  112.   repeat with x in urlList
  113.     if x.uniqueID = link then
  114.       return x
  115.     end if
  116.   end repeat
  117.   return 0
  118. end
  119.  
  120. on getPropfromUID me, link, aprop
  121.   repeat with x in urlList
  122.     if x.uniqueID = link then
  123.       return getaProp(x, aprop)
  124.     end if
  125.   end repeat
  126.   return 0
  127. end
  128.  
  129. on search me
  130.   fileObj = new(xtra("fileio"))
  131.   answer = displayOpen(fileObj)
  132.   if answer = EMPTY then
  133.     return 
  134.   end if
  135.   delete char 1 to the number of chars in the moviePath of answer
  136.   if checkDuplicate(me, answer) then
  137.     alert("duplicate")
  138.     return 
  139.   end if
  140.   fileObj = 0
  141. end
  142.  
  143. on checkDuplicate me, answer
  144.   repeat with x in urlList
  145.     if x.originalpath = answer then
  146.       return 1
  147.     end if
  148.   end repeat
  149.   addURL(me, answer)
  150.   return 0
  151. end
  152.  
  153. on addURL me, apath
  154.   add(urlList, new(script("linkParent"), 0, apath))
  155. end
  156.  
  157. on getURLList me
  158.   temp = EMPTY
  159.   repeat with x = 1 to count(urlList)
  160.     obj = getAt(urlList, x)
  161.     put obj.originalpath into line x of temp
  162.   end repeat
  163.   return temp
  164. end
  165.